package com.doupi.partner.constant;

/**
 * 合伙人类型
 * 
 * @author zhangshixuan
 * @version 1.0.0 @ 2017-04-14
 */
public enum PartnerTypeEnum {
	SECOND("二级城市合伙人", Byte.valueOf("1")), SUPERIOR("一级城市合伙人", Byte.valueOf("2")), CITY("城市代理商", Byte.valueOf("3")), SUBSTATION("分站", Byte.valueOf("4")), HEADQUARTERS("总部", Byte.valueOf("5"));

	private String name;
	private byte code;

	PartnerTypeEnum(String name, byte code) {
		this.name = name;
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public byte getCode() {
		return code;
	}

	/**
	 * 根据 code获取profile
	 *
	 * @param code
	 *            code
	 * @return {@link PartnerTypeEnum}
	 */
	public static PartnerTypeEnum getPartnerTypeByCode(byte code) {
		for (PartnerTypeEnum partnerType : values()) {
			if (code == partnerType.code) {
				return partnerType;
			}
		}
		return null;
	}
}
